//游戏总管理类
import GameManger from "./manager/GameManger";
import EventManager from "./manager/EventManager";
import ResourceManger from "./manager/ResourceManger";
import ConfigManager from "./manager/ConfigManager";
import SceneManager from "./manager/SceneManager";
import { SoundsManager } from "./manager/SoundsManager";
import TipManager from "./manager/TipManager";
import SDKManager from "./manager/SDK/SDKManager";
import LevelManager from "./manager/LevelManager";
import AtlasManager from "./manager/AtlasManager";

declare global {
    interface Window {
        gameFacade: GameFacade;
    }
}

export default  class GameFacade {
    private static _instance: GameFacade = null;
    private _gameMng: GameManger;
    // public AudioMng: manager.AudioManager;
    private _resourceMng: ResourceManger;
    private _eventMng: EventManager;
    private _configManager: ConfigManager;
    private _sceneManager: SceneManager;
    private _soundManager: SoundsManager;
    private _sdkManager:SDKManager;
    private _tipManager: TipManager;
    private _levelManager:LevelManager;
    private _atlasManager:AtlasManager;
    
    public get GameMng(): GameManger {
        if (null == this._gameMng)
            this._gameMng = new GameManger();
        return this._gameMng;
    }
    public get ResourceMng(): ResourceManger {
        if (null == this._resourceMng)
            this._resourceMng = new ResourceManger();
        return this._resourceMng;
    }
 
    public get EventMng(): EventManager {
        if (null == this._eventMng)
            this._eventMng = new EventManager();
        return this._eventMng;
    }

    public get ConfigMng(): ConfigManager {
        if (null == this._configManager)
            this._configManager = new ConfigManager();
        return this._configManager;
    }
    public get SceneMng(): SceneManager {
        if (null == this._sceneManager)
            this._sceneManager = new SceneManager();
        return this._sceneManager;
    }

    public get SoundMng(): SoundsManager {
        if (null == this._soundManager)
            this._soundManager = new SoundsManager();
        return this._soundManager;
    }

    public get TipMng(): TipManager {
        if (null == this._tipManager)
            this._tipManager = new TipManager();
        return this._tipManager;
    }

    public get SDKMng(): SDKManager {
        if (null == this._sdkManager)
            this._sdkManager = new SDKManager();
        return this._sdkManager;
    }

    public get LevelMng(): LevelManager {
        if (null == this._levelManager)
            this._levelManager = new LevelManager();
        return this._levelManager;
    }

    public get AtlasMng(): AtlasManager {
        if (null == this._atlasManager)
            this._atlasManager = new AtlasManager();
        return this._atlasManager;
    }

    /**
     * 初始化所有的管理器类
     */
    Init(): void {
        this.GameMng.Init();
        this.ResourceMng.Init();
        this.EventMng.Init();
        this.ConfigMng.Init();
        this.SceneMng.init();
        this.TipMng.Init();
        this.SDKMng.Init();
        this.LevelMng.Init();
        this.AtlasMng.Init();
    }

    public static get Instance(): GameFacade {
        if (this._instance == null) {
            this._instance = new GameFacade();
            window.gameFacade = this._instance;
        }
        return this._instance;
    }
}
